package pcb.control.responders 
{
	import com.intel.service.ServiceEvent;
	import com.intel.utils.Debugger;
	import flash.xml.XMLNode;
	import pcb.control.events.LoadDataEvent;
	import pcb.models.Notifications;
	import pcb.models.PlayerSettings;
	
	/**
	 * ...
	 * @author Fintan Boyle
	 */
	public class Re_loadLessonText extends AbstractResponder 
	{
		private var notify:String;
		public function Re_loadLessonText(notifyId:String=Notifications.LESSON_LOCALE_READY) 
		{
			notify = notifyId;
		}
		
		override public function result(e:ServiceEvent):void 
		{
			Debugger.traceOut("Re_loadLessonText >>" +e.type + " - " + e.message);
			
			models.localeModel.addLabels(XML(e.data));
			models.localeModel.notifyViews(notify);
			
			if (notify == Notifications.LESSON_LOCALE_READY) {
				var ev2:LoadDataEvent = new LoadDataEvent(LoadDataEvent.LOAD_LESSON_XML);
				ev2.data = models.lessonStateModel.lessonId;
				ev2.dispatch();
			}else {
				
				var evChkProcessor:LoadDataEvent = new LoadDataEvent(LoadDataEvent.INTEL_PROCESSOR_CHECK);
				evChkProcessor.dispatch();
				/*
				//TODO maybe place in its own command in interests of ease of understanding?
				
				//proceed based on player type
				//web version doesn't require a processor check
				if(models.playerSettings.deployment != "cd" && models.playerSettings.deployment != "desktop"){
				//if(models.playerSettings.playerType == PlayerSettings.SINGLE_LESSON){
					
					var ev:LoadDataEvent = new LoadDataEvent(LoadDataEvent.RETRIEVE_LESSON_ID);
					ev.dispatch();
						
					if(models.playerSettings.useMainMenu) if(!models.playerStateModel.activated){
						var evMenu:LoadDataEvent = new LoadDataEvent(LoadDataEvent.LOAD_MAIN_MENU);
						evMenu.dispatch();
					}
						
					models.playerStateModel.activated = true;
					
				}else { //assumes that a 'multi' player is always deployed on a CD requiring a processor check
					
					var evChkProcessor:LoadDataEvent = new LoadDataEvent(LoadDataEvent.INTEL_PROCESSOR_CHECK);
					evChkProcessor.dispatch();
				}
				*/
				
			}
			
			super.cleanup(e);
		}		
	}
	
}